package com.huluobo.a2205parkdemo.department

import androidx.lifecycle.MutableLiveData
import com.huluobo.base.mvvm.BaseViewModel
import com.huluobo.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import okhttp3.RequestBody
import javax.inject.Inject

/**
 *  Created by LC on 2024/9/28.
 */
@HiltViewModel
class DepartmentViewModel @Inject constructor(
    val apiService: ApiService
) : BaseViewModel() {
    val getAllDepartmentSuccess by lazy { MutableLiveData<String>() }
    fun getAllDepartment(body: RequestBody) {
        executeNetRequest(
            { apiService.getAllDepartment(body) },
            getAllDepartmentSuccess::postValue
        )
    }

    val addDepartmentSuccess by lazy { MutableLiveData<String>() }
    fun addDepartment(body: RequestBody) {
        executeNetRequest(
            { apiService.addDepartment(body) },
            addDepartmentSuccess::postValue
        )
    }

    val deleteDepartmentSuccess by lazy { MutableLiveData<String>() }
    fun deleteDepartment(body: RequestBody) {
        executeNetRequest(
            { apiService.deleteDepartment(body) },
            deleteDepartmentSuccess::postValue
        )
    }
}